package com.leo.model;

import com.leo.util.DateUtil;
import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

import java.beans.PropertyDescriptor;

/**
 * @ClassName: MyInstantiationAwareBeanPostProcessor
 * @Description: ${description}
 * @Author: leo825
 * @Date: 2020-02-24 21:27
 * @Version: 1.0
 */
public class MyInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter {

    public MyInstantiationAwareBeanPostProcessor(){
        super();
        System.out.println(DateUtil.getTimeNow() + "调用InstantiationAwareBeanPostProcessor构造方法");
    }

    @Override
    public Object postProcessBeforeInstantiation(Class<?> aClass, String s) throws BeansException {
        System.out.println(DateUtil.getTimeNow() + "调用InstantiationAwareBeanPostProcessor的postProcessBeforeInstantiation(),[" + s + "]");
        return null;
    }

    @Override
    public boolean postProcessAfterInstantiation(Object o, String s) throws BeansException {
        boolean resule = true;
        System.out.println(DateUtil.getTimeNow() + "调用InstantiationAwareBeanPostProcessor的postProcessAfterInstantiation(),[" + s + "], 返回: "+ resule);
        return resule;
    }

    @Override
    public PropertyValues postProcessPropertyValues(PropertyValues propertyValues, PropertyDescriptor[] propertyDescriptors, Object o, String s) throws BeansException {
        System.out.println(DateUtil.getTimeNow() + "调用InstantiationAwareBeanPostProcessor的postProcessPropertyValues(),[" + s + "]");
        return propertyValues;
    }
}
